package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyCollection;
import cn.wolfcode.trip.base.domain.TravelCollection;
import cn.wolfcode.trip.base.mapper.StrategyCollectionMapper;
import cn.wolfcode.trip.base.mapper.TravelCollectionMapper;
import cn.wolfcode.trip.base.query.TravelCollectionQuery;
import cn.wolfcode.trip.base.service.IStrategyCollectionService;
import cn.wolfcode.trip.base.service.ITravelCollectionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StrategyCollectionServiceImpl implements IStrategyCollectionService {

    @Autowired
    private StrategyCollectionMapper strategyCollectionMapper;

    @Override
    public void save(Long userId,Long strategyId) {

        strategyCollectionMapper.insert(userId,strategyId,new Date());
    }

    @Override
    public StrategyCollection get(Long userId, Long strategyId) {
        return strategyCollectionMapper.get(userId, strategyId);
    }

    @Override
    public void delete(Long userId, Long strategyId) {
        strategyCollectionMapper.delete(userId,strategyId);
    }

    @Override
    public PageInfo<StrategyCollection> list(TravelCollectionQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyCollection> list = strategyCollectionMapper.selectAll();
        return new PageInfo<>(list);
    }


}
